package com.wangzh.nio.output;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class ByteStreamDemo2 {
    public static void main(String[] args) throws IOException {

        test2();
    }

//换行写
//    续写

    private static void test2() throws IOException {
        FileOutputStream fos = new FileOutputStream("b.txt",true);

        /**
         * 换行符
         *      Windows ： \r\n
         *      Linux:  \n
         *      Mac:    \r
         *  细节：
         *  java对回车换行进行了优化
         */
        String str = "qwe";
        byte[] bytes = str.getBytes();
        fos.write(bytes);
//回车换行
        String wrap = "\r\n";
        fos.write(wrap.getBytes());

        String str2 = "6541";
        byte[] bytes2 = str2.getBytes();
        fos.write(bytes2);
        fos.close();
    }
    private static void test() throws IOException {
        FileOutputStream fos = new FileOutputStream("b.txt");
        byte[] arr = {'a','b','c'};

        fos.write(arr);

        fos.close();
    }


}
